package com.eco.fanliapp.common.base;

import com.alibaba.fastjson.JSONObject;
import com.eco.fanliapp.entity.Administrator;
import com.eco.fanliapp.vo.UserVO;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @ProjectName: fanliapp
 * @Package: com.eco.fanliapp.common.base
 * @ClassName: BaseController
 * @Author: LC
 * @Description:
 * @Date: 2019/11/28 15:13
 * @Version: 4.2.2
 */
public class BaseController extends AuthController{
    public UserVO getAuthentication() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        try{
            UserVO userVO = JSONObject.parseObject((String) authentication.getPrincipal(), UserVO.class);
            return userVO;
        }catch (Exception e){

        }
        return null;
    }



    public Administrator getKfAuthentication() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        try{
            Administrator imKfInfo = JSONObject.parseObject((String) authentication.getPrincipal(), Administrator.class);
            return imKfInfo;
        }catch (Exception e){

        }
        return null;
    }



}